<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>区块链资产管理系统</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --accent-color: #e74c3c;
            --light-color: #ecf0f1;
            --dark-color: #2c3e50;
            --success-color: #2ecc71;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Roboto', sans-serif;
            background-color: #f5f7fa;
            color: var(--dark-color);
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 20px 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            font-size: 24px;
            font-weight: 700;
            display: flex;
            align-items: center;
        }
        
        .logo i {
            margin-right: 10px;
            color: var(--light-color);
        }
        
        nav ul {
            display: flex;
            list-style: none;
        }
        
        nav ul li {
            margin-left: 20px;
        }
        
        nav ul li a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        
        nav ul li a:hover {
            color: var(--light-color);
        }
        
        .hero {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .hero h1 {
            font-size: 36px;
            margin-bottom: 15px;
            color: var(--primary-color);
        }
        
        .hero p {
            font-size: 18px;
            color: #7f8c8d;
            max-width: 700px;
            margin: 0 auto 30px;
        }
        
        .card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            padding: 25px;
            margin-bottom: 30px;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }
        
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            border-bottom: 1px solid #eee;
            padding-bottom: 15px;
        }
        
        .card-header h2 {
            font-size: 22px;
            color: var(--primary-color);
        }
        
        .card-header i {
            font-size: 24px;
            color: var(--secondary-color);
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark-color);
        }
        
        input, select, textarea {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            transition: border 0.3s ease;
        }
        
        input:focus, select:focus, textarea:focus {
            border-color: var(--secondary-color);
            outline: none;
        }
        
        button {
            background-color: var(--secondary-color);
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            transition: background-color 0.3s ease;
        }
        
        button:hover {
            background-color: #2980b9;
        }
        
        .btn-danger {
            background-color: var(--accent-color);
        }
        
        .btn-danger:hover {
            background-color: #c0392b;
        }
        
        .btn-success {
            background-color: var(--success-color);
        }
        
        .btn-success:hover {
            background-color: #27ae60;
        }
        
        .result-container {
            margin-top: 30px;
            padding: 20px;
            background-color: #f8f9fa;
            border-radius: 4px;
            border-left: 4px solid var(--secondary-color);
        }
        
        .result-title {
            font-weight: 500;
            margin-bottom: 10px;
            color: var(--primary-color);
        }
        
        .asset-details {
            margin-top: 20px;
        }
        
        .asset-details p {
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
        
        .asset-details p:last-child {
            border-bottom: none;
        }
        
        .asset-details strong {
            color: var(--primary-color);
            margin-right: 10px;
        }
        
        footer {
            text-align: center;
            padding: 20px 0;
            margin-top: 50px;
            background-color: var(--primary-color);
            color: white;
        }
        
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 30px;
        }
        
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
            }
            
            nav ul {
                margin-top: 20px;
            }
            
            nav ul li {
                margin: 0 10px;
            }
            
            .grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <header>
        <div class="container header-content">
            <div class="logo">
                <i class="fas fa-link"></i>
                <span>区块链资产管理系统</span>
            </div>
            <nav>
                <ul>
                    <li><a href="#create">资产上链</a></li>
                    <li><a href="#query">查询资产</a></li>
                    <li><a href="#transfer">转移资产</a></li>
                </ul>
            </nav>
        </div>
    </header>
    
    <div class="container">
        <section class="hero">
            <h1>Hyperledger Fabric 资产管理</h1>
            <p>使用区块链技术安全地创建、查询和转移数字资产。所有交易记录永久保存在分布式账本中，确保透明性和不可篡改性。</p>
        </section>
        
        <div class="grid">
            <section id="create" class="card">
                <div class="card-header">
                    <h2>资产上链</h2>
                    <i class="fas fa-plus-circle"></i>
                </div>
                <form id="createForm">
                    <div class="form-group">
                        <label for="createId">资产ID</label>
                        <input type="text" id="createId" required placeholder="输入唯一资产标识符">
                    </div>
                    <div class="form-group">
                        <label for="createOwner">所有者</label>
                        <input type="text" id="createOwner" required placeholder="输入所有者名称">
                    </div>
                    <div class="form-group">
                        <label for="createName">资产名称</label>
                        <input type="text" id="createName" required placeholder="输入资产名称">
                    </div>
                    <div class="form-group">
                        <label for="createInfo">资产信息</label>
                        <textarea id="createInfo" rows="3" placeholder="输入资产详细信息"></textarea>
                    </div>
                    <button type="submit" class="btn-success">
                        <i class="fas fa-save"></i> 保存到区块链
                    </button>
                </form>
                <div id="createResult" class="result-container" style="display: none;">
                    <div class="result-title">交易结果</div>
                    <div id="createResultContent"></div>
                </div>
            </section>
            
            <section id="query" class="card">
                <div class="card-header">
                    <h2>查询资产</h2>
                    <i class="fas fa-search"></i>
                </div>
                <form id="queryForm">
                    <div class="form-group">
                        <label for="queryId">资产ID</label>
                        <input type="text" id="queryId" required placeholder="输入要查询的资产ID">
                    </div>
                    <button type="submit">
                        <i class="fas fa-search"></i> 查询资产
                    </button>
                </form>
                <div id="queryResult" class="result-container" style="display: none;">
                    <div class="result-title">资产详情</div>
                    <div id="queryResultContent" class="asset-details"></div>
                </div>
            </section>
            
            <section id="transfer" class="card">
                <div class="card-header">
                    <h2>转移资产</h2>
                    <i class="fas fa-exchange-alt"></i>
                </div>
                <form id="transferForm">
                    <div class="form-group">
                        <label for="transferId">资产ID</label>
                        <input type="text" id="transferId" required placeholder="输入要转移的资产ID">
                    </div>
                    <div class="form-group">
                        <label for="transferOwner">新所有者</label>
                        <input type="text" id="transferOwner" required placeholder="输入新所有者名称">
                    </div>
                    <button type="submit" class="btn-danger">
                        <i class="fas fa-exchange-alt"></i> 转移所有权
                    </button>
                </form>
                <div id="transferResult" class="result-container" style="display: none;">
                    <div class="result-title">转移结果</div>
                    <div id="transferResultContent"></div>
                </div>
            </section>
        </div>
    </div>
    
    <footer>
        <div class="container">
            <p>&copy; 2023 区块链资产管理系统. 使用Hyperledger Fabric构建.</p>
        </div>
    </footer>
    
    <script>
        // 这里添加与区块链交互的JavaScript代码
        document.getElementById('createForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const id = document.getElementById('createId').value;
            const owner = document.getElementById('createOwner').value;
            const name = document.getElementById('createName').value;
            const info = document.getElementById('createInfo').value;
            
            // 这里应该是与区块链交互的代码
            // 例如: const result = await createAssetOnChain(id, owner, name, info);
            
            // 模拟响应
            const result = {
                success: true,
                transactionId: 'tx_' + Math.random().toString(36).substr(2, 9),
                message: `资产 ${id} 已成功上链`
            };
            
            document.getElementById('createResultContent').innerHTML = `
                <p><strong>状态:</strong> ${result.success ? '成功' : '失败'}</p>
                <p><strong>交易ID:</strong> ${result.transactionId}</p>
                <p><strong>消息:</strong> ${result.message}</p>
            `;
            document.getElementById('createResult').style.display = 'block';
            
            // 清空表单
            if(result.success) {
                this.reset();
            }
        });
        
        document.getElementById('queryForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const id = document.getElementById('queryId').value;
            
            // 这里应该是与区块链交互的代码
            // 例如: const asset = await queryAssetOnChain(id);
            
            // 模拟响应
            const asset = {
                id: id,
                owner: '模拟所有者_' + Math.floor(Math.random() * 100),
                name: '模拟资产_' + Math.floor(Math.random() * 100),
                info: '这是存储在区块链上的模拟资产信息。实际应用中，这里会显示从链上查询到的真实数据。',
                timestamp: new Date().toISOString()
            };
            
            document.getElementById('queryResultContent').innerHTML = `
                <p><strong>资产ID:</strong> ${asset.id}</p>
                <p><strong>所有者:</strong> ${asset.owner}</p>
                <p><strong>资产名称:</strong> ${asset.name}</p>
                <p><strong>资产信息:</strong> ${asset.info}</p>
                <p><strong>最后更新时间:</strong> ${new Date(asset.timestamp).toLocaleString()}</p>
            `;
            document.getElementById('queryResult').style.display = 'block';
        });
        
        document.getElementById('transferForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const id = document.getElementById('transferId').value;
            const newOwner = document.getElementById('transferOwner').value;
            
            // 这里应该是与区块链交互的代码
            // 例如: const result = await transferAssetOnChain(id, newOwner);
            
            // 模拟响应
            const result = {
                success: true,
                transactionId: 'tx_' + Math.random().toString(36).substr(2, 9),
                message: `资产 ${id} 已成功转移给 ${newOwner}`
            };
            
            document.getElementById('transferResultContent').innerHTML = `
                <p><strong>状态:</strong> ${result.success ? '成功' : '失败'}</p>
                <p><strong>交易ID:</strong> ${result.transactionId}</p>
                <p><strong>消息:</strong> ${result.message}</p>
            `;
            document.getElementById('transferResult').style.display = 'block';
            
            // 清空表单
            if(result.success) {
                this.reset();
            }
        });
    </script>
</body>
</html>